package com.zookeeper.consumer.controller;

import com.zookeeper.consumer.feign.CoffeeService;
import com.zookeeper.consumer.model.Coffee;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 超
 * Create by fengc on  2022/10/1 00:05
 */
@RestController
@RequestMapping("/coffee")
@Slf4j
public class CoffeeController {

    @Resource
    private CoffeeService coffeeService;

    @GetMapping(path = "/getAll")
    List<Coffee> getAll() {
        log.info("查询所有咖啡.......");
        return coffeeService.getAll();
    }

    @GetMapping("/{id}")
    Coffee getById(@PathVariable Long id) {
        log.info("通过主键查询咖啡.......");
        return coffeeService.getById(id);
    }

    @GetMapping(path = "/", params = "name")
    Coffee getByName(@RequestParam String name) {
        log.info("通过名称查询咖啡.......");
        return coffeeService.getByName(name);
    }

}
